<!--This Plugin was Written By Atwood Kang-->
<!--该页面由 Atwood Kang 编写-->
<!--基于 Apache-2.0-->

<!--
    _   _                           _   _  __                 
   / \ | |___      _____   ___   __| | | |/ /__ _ _ __   __ _ 
  / _ \| __\ \ /\ / / _ \ / _ \ / _` | | ' // _` | '_ \ / _` |
 / ___ \ |_ \ V  V / (_) | (_) | (_| | | . \ (_| | | | | (_| |
/_/   \_\__| \_/\_/ \___/ \___/ \__,_| |_|\_\__,_|_| |_|\__, |
                                                        |___/ 
-->


<?php
$return_url = $_GET['url'];
$token = $_GET['token'];
$id = $_GET['id'];
$time = $_GET['time'];

if (md5($id) == $token) {
    $token_list = json_decode(file_get_contents("token.json"), true);
    $name = array_search($id, $token_list);
    // ===========
    if (isset($_COOKIE['username'], $_COOKIE['token'])) {
        $data = json_encode(["username" => $_COOKIE['username']]);
        $curl = $return_url;
        curl_setopt($curl, CURLOPT_HEADER, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_exec($curl);
        curl_close($curl);

    } else { echo 'Login first'; }
    // ===========
} else {
    header("Location: ".$return_url);
}